﻿using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Service
{
    /// <summary>
    /// 服务层基类
    /// </summary>
    /// <typeparam name="M"></typeparam>
    /// <typeparam name="T"></typeparam>
    public interface BaseService<M, T>
    {

        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="t"></param>
        BaseResult<int> Save(T t);
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="t"></param>
        BaseResult<int> Update(T t);
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="m">唯一标识</param>
        /// <returns></returns>
        BaseResult<int> Delete(M m);
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        BaseResult<List<T>> Search(T t);
        /// <summary>
        /// 通过主键查询
        /// </summary>
        /// <param name="m">主键</param>
        /// <returns></returns>
        BaseResult<T> SearchByPrimaryKey(M m);
        /// <summary>
        /// 查询一个结果（如果有多个结果，取第一个）
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        BaseResult<T> SearchOne(T t);
    }
}
